//
//  SortViewController.m
//  LoveHappyShopping
//
//  Created by 白水非泉 on 16/6/23.
//  Copyright © 2016年 白水非泉. All rights reserved.
//

#import "SortViewController.h"

@interface SortViewController ()
@property(nonatomic,strong)UIView *navTitleView;
@end

@implementation SortViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setNavBar];
    // Do any additional setup after loading the view.
}
-(void)setNavBar{
    int btnW=46;
    int btnH=33;
    UIView *navTitleView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, btnW*3, btnH)];
    
    UIButton *fenleiBtn=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, btnW, btnH)];
    [fenleiBtn setBackgroundImage:[UIImage imageNamed:@"fenlei"] forState:UIControlStateNormal];
    [fenleiBtn setBackgroundImage:[UIImage imageNamed:@"fenleiselected"] forState:UIControlStateSelected];
    [fenleiBtn addTarget:self action:@selector(feileiClick:) forControlEvents:UIControlEventTouchUpInside];
    UIButton *changjingBtn=[[UIButton alloc]initWithFrame:CGRectMake(btnW, 0, btnW, btnH)];
    [changjingBtn setBackgroundImage:[UIImage imageNamed:@"changjing"] forState:UIControlStateNormal];
    [changjingBtn setBackgroundImage:[UIImage imageNamed:@"changjingselected"] forState:UIControlStateSelected];
    changjingBtn.selected=YES;
    [changjingBtn addTarget:self action:@selector(changjingClick:) forControlEvents:UIControlEventTouchUpInside];
    [navTitleView addSubview:fenleiBtn];
    [navTitleView addSubview:changjingBtn];
    self.navTitleView=navTitleView;
    self.navigationItem.titleView=navTitleView;
}
-(void)feileiClick:(UIButton *)btn{
    for (UIButton *button in self.navTitleView.subviews) {
        button.selected=YES;
    }
    btn.selected=NO;
    
}
-(void)changjingClick:(UIButton *)btn{
    for (UIButton *button in self.navTitleView.subviews) {
        button.selected=YES;
    }
    btn.selected=NO;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
